home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
090
/
byt85mar.lbr
/
MAC10.BQS
/
MAC10.BAS
Wrap
BASIC Source File
|
1985-09-15
|
3KB
|
108 lines
5 REM *** "MAC10/BAS" *** DECIMAL BASED MACHINE LANGUAGE EMULATION
7 REM *** BY: JOHN R. ROBBINS, HUNTSVILLE, ALABAMA
10 DIM M(99)
20 CLS
30 T$="### ## ### #### \ \"
40 T=0
50 INPUT"DO YOU WANT A TRACE (Y/N)";A$
60 IF LEFT$(A$,1)="Y" THEN T=1
70 READ A$
80 C$=LEFT$(A$,3)
90 IF C$="RUN" THEN 170
100 IF C$<>"LOA" THEN 150: REM INITIAL STATEMENTS MUST BE LOAD THEN RUN
110 XX=VAL(MID$(A$,6,2)) : REM GET MEMORY LOCATION
120 A=VAL(MID$(A$,9,4)) : REM GET VALUE TO BE LOADED
130 GOSUB 470
140 GOTO 70
150 PRINT "INVALID INPUT - ";A$
160 STP10 PC=0 : E ST PC TO 0TE HECK IF DEFINED BY RUN
180 IFLNA)>4 THEN PC=VAL(MID$(A$,5,2))
190 PRINT "EXECUTION STATDA ;PC
200 IF T=0 THEN 260
210 LPRINT IIILSATE OF MEMORY" : LPRINT
220 OU 70
230 LPRINT " EEUIN STARTED AT ";PC : LPRINT
240 LPRINT C MD VAL AC
250 REM *** LOOP FOR RUNNING PROGRAM STAT EE ***
260 V=M(PC) : RM ET VALUE OF NEXT PROGRAM INSTRUCTION
270 C=IN(/0): REM GET OP CODE NUMBER
280 XX=V-C*100 : REM E EOY CELL NUMBER
290 IF C=0 THEN 700
30O OSUB 350,390,430,470,510,540,580,620,6030I T=0 THEN 260
320LRN USING T$;PC,C,XX,A,C$
330 GOTO 260
340 REM ASSIGNMENT OF $TLSPURPOSE OF SUBROUTINE
350C=RA A VALUEIT H ACCUMULATOR"
360 READ A
370 PC=PC+1
380 RETR
9 C$="OUTPUT THE VALUE IN THE ACMLTR"
400 PIT:LPRINT "* UPUT VAU="A: LPRINT
410 PC=PC+1
420 RETURN
43 $"OAD CONTENTS OF"+STR$(XX)+" INTO A"40AMXX)
450 P=C1460 RETUN40C="STORE CONTENTS OF A IN"+STR$(XX)
480 M(XX)A40PC=PC+1
500 RETURN
510 C$="JUMP TO"+STR$(XX)
520 PCX
3 ETURN
540 C$="IFA<0THEN JUM O+T$(XX)
550 PC=PC+1
560 FA0THEN CX
70 REUN50 C$="IF A = 0 THEN JUMP TO"SR(X
590 PC=C160 IF A=0 THE CX
10 RETURN
620 C$="ADD CONTENTS OF"+ST$X)"TO A"
630 A=A+M(XX)
64 CP+
650 REUN60 C$="SUBTRACT CONTENTS OF"+STR$(X)"FO A"
670 A=-(X
68 CP+
690 RETURN
700 PRINT "HALT AT ";PC
710 IF T=0 HNED720 LPITHLT A ;C70 LPRIN H$1)
740 LPRINT : LPRIN"IA STATE OF MEMORY" : LPRINT
750 GOSUB 770
70ED70 FOR I=0 TO 90 STEP 10
780 FOR J=0 TO 9
790LRN USING "####;(+J);
800 NEXT J
810 LPRINT80NX
830 LPRINT
80RTR
850 REM PROGRAM DT OLWS
860DT OD 00 100 :RE EDA NUMBER
7 AALA 01 715 :REM IF N=0 THENJM O15 TO STOP
880 DATA LOAD 02 9 :E STORE N IN 99
890 DATA LOAD 03 100 :REM READ IN THE FIRST VALUE, A
900 DATA LOAD 04 497 :REM STORE A IN 97
910 DATA LOAD 05 100 :REM READ IN NEXT VALUE, B
920 DATA LOAD 06 496 :REM STORE B IN 96
930 DATA LOAD 07 100 :REM READ IN FINAL NUMBER, C
940 DATA LOAD 08 897 :REM ADD A TO C
950 DATA LOAD 09 996 :REM SUBTRACT B
960 DATA LOAD 10 996 :REM SUBTRACT B AGAIN GIVING A-2*B+C
970 DATA LOAD 11 200 :REM PRINT THE RESULTS
980 DATA LOAD 12 399 :REM LOAD N INTO THE ACCUMULATOR
990 DATA LOAD 13 998 :REM SUBTRACT 1 (DECREMENT)
1000 DATA LOAD 14 501 :REM JUMP TO 01
1010 DATA LOAD 15 000 :REM HALT PROGRAM
1020 DATA LOAD 98 001 :REM LOAD IN THE VALUE 1 FOR USE IN DECREMENTING
1030 DATA RUN
1040 DATA 2
1050 DATA 3
1060 DATA 2
1070 DATA 4
1080 DATA 23
1090 DATA 51
1100 DATA 36
IN DECREMENTING
1030 DATA RUN
1040 DATA 2
1050 DATA 3
1060 DATA 2
1070 DATA 4
1080 DATA 23
1090 DATA 51
1100 DATA 3